﻿@{
    ViewData["Title"] = "提升机信息配置";
    ViewData["Mbx"] = "配置管理";
    Layout = "_Default";
}

@section css {
    <style>

        .fliter {
            width: 95%;
            height: 40px;
            align-items: center;
            display: flex;
            margin-bottom: 10px;
        }

        .add {
            width: 80%;
            height: 60px;
            align-items: center;
            display: flex;
            margin-left: 20px;
        }

        .fliter .search-btn {
            margin-left: 20px;
        }

        .fliter .input-text {
            width: 180px;
        }

        .fliter .label-eq-code {
            margin-left: 20px;
        }

        .fliter .input-text-eq-code {
            width: 180px;
        }

        .fliter .input-text-dbcode {
            width: 180px;
        }

        .fliter .label-eq-name {
            margin-left: 20px;
        }

        .select-box {
            width: 180px;
        }
    </style>
}

@section gray {
    @*<div class="add">
    <span class="l">
        <a class="btn btn-primary radius" href="javascript:;" onclick="common_add('添加PLC点位配置','/plcpointinfo/plcpointinfoaddoredit','600','600')">
            <i class="Hui-iconfont">&#xe600;</i> 新增
        </a>
    </span>
</div>*@

    <div class="fliter">
        <label class="label-eq-name">十字路口：</label>
        <input type="text" class="input-text" value="" placeholder="请输入设备号" id="CrossroadEquipmentCode" name="CrossroadEquipmentCode">
        @*<label class="label-eq-code">提升机：</label>
    <input type="text" class="input-text input-text-eq-code" value="" placeholder="请输入提升机" id="elevatorCode" name="elevatorCode">
    <label class="label-eq-code">连接IP：</label>
    <span class="select-box">
    <select class="select" size="1" name="ipSearch" id="ipSearch">
    <option value="0" selected>--请选择--</option>
    @foreach (var item in Model.PlcIpSearchs)
    {
    <option value="@item.PlcConnectId">@item.PlcConnectIp</option>
    }
    </select>
    </span>*@
        <input class="btn btn-primary radius search-btn" type="button" onclick="search()" value="&nbsp;&nbsp;搜索&nbsp;&nbsp;">
    </div>

    <div>
        <span class="l">
            <a class="btn btn-primary radius" href="javascript:;" onclick="common_add('添加提升机十字口配置','/elevatorMasterInfo/ElevatorMasterInfoAddOrEdit','700','460')">
                <i class="Hui-iconfont">&#xe600;</i> 新增
            </a>
        </span>

    </div>
}
<table class="table table-border table-bordered table-hover table-bg table-sort">
    <thead>
    </thead>
    <tbody>
    </tbody>
</table>

@section javascript {
    <script>
        $(function () {
            initData("");
        });


        function search() {
            var CrossroadEquipmentCode = $("#CrossroadEquipmentCode").val();
            initData(CrossroadEquipmentCode);
        }

        function initData(CrossroadEquipmentCode) {
            $('.table-sort').dataTable({
                bProcessing: true, //DataTables 载入数据时，是否显示‘进度’提示
                bAutoWidth: true, //自动宽度
                bSort: false, //排序功能
                sScrollX: true, //横向滑动
                paging: true, //是否分页
                bInfo: true, //页脚信息,默认为 true
                bStateSave: false, //状态保存
                sPaginationType: "full_numbers", //分页显示样式
                serverSide: true, //启用服务器分页
                //sAjaxSource: "/admin/functionlist", //服务端请求数据接口
                searching: false, //关闭 datatables 的搜索框
                destroy: true, //解决重新渲染问题
                aLengthMenu: [50, 100, 200, 500, 1000],
                iDisplayLength: 50, //每页显示数量
                ajax: {
                    url: "/elevatorMasterInfo/getelevatorMasterinfos",
                    type: "POST",
                    contentType: "application/x-www-form-urlencoded",
                    async: false,
                    dataType: "json",
                    data: function (data) {
                        data.CrossroadEquipmentCode = CrossroadEquipmentCode;
                    },
                    dataFilter: function (json) {
                        console.log(json);
                        return json;
                    }
                },

                aoColumns: [
                    // mDataProp：绑定数据属性
                    // sDefaultContent：设置默认值
                    // sClass：添加 class 属性，不懂的直接去掉
                    // sTtile：设置列标题
                    // sWidth：设置列宽度
                    // sTtile 设置的内容，会替换到 html thead 中的“标题”
                    //{mDataProp:"js_Id", sClass:"text-c",  sTitle:"编号",sDefaultContent:""},
                    { mDataProp: "js_Id", sClass: "text-c", sTitle: "ID", sDefaultContent: "", sWidth: "150px" },
                    { mDataProp: "elevatorCode", sClass: "text-c", sTitle: "提升机", sDefaultContent: "", sWidth: "75px" },
                    { mDataProp: "crossroadEquipmentCode", sClass: "text-c", sTitle: "十字路口", sDefaultContent: "", sWidth: "75px" },
                    { mDataProp: "nextElevatorCodes", sClass: "text-c", sTitle: "接后提升机十字口", sDefaultContent: "", sWidth: "250px" },
                    { mDataProp: "elevatorPUCode", sClass: "text-c", sTitle: "提升机入口", sDefaultContent: "", sWidth: "75px" },
                    { mDataProp: "elevatorDOCodes", sClass: "text-c", sTitle: "提升机出口", sDefaultContent: "", sWidth: "350px" },

                    { mDataProp: "canToEquipments", sClass: "text-c", sTitle: "可去目标设备", sDefaultContent: "", sWidth: "380px" },
                    {
                        mDataProp: "isEnable", sClass: "text-c", sTitle: "启用", sDefaultContent: "", sWidth: "100px",
                        mRender: function (data, type, row) {

                            var html = "<div class=\"switch has-switch\" onclick=\"ModifyElesStatusAsync('" + data + "','" + row.js_Id + "')\" data-on=\"danger\" data-off=\"primary\" data-on-label=\"<i class='icon-ok icon-white'>启用</i>\" data-off-label=\"<i class='icon-remove'>禁用</i>\"><div class=\"switch-off switch-animate\"><input type=\"checkbox\" checked><span class=\"switch-left switch-danger\"><i class=\"icon-ok icon-white\">启用</i></span><label>&nbsp;</label><span class=\"switch-right switch-primary\"><i class=\"icon-remove\">禁用</i></span></div></div>";
                            if (data) {
                                html = "<div class=\"switch has-switch\" onclick=\"ModifyElesStatusAsync('" + data + "','" + row.js_Id + "')\" data-on=\"danger\" data-off=\"primary\" data-on-label=\"<i class='icon-ok icon-white'>启用</i>\" data-off-label=\"<i class='icon-remove'>禁用</i>\"><div class=\"switch-on switch-animate\"><input type=\"checkbox\" checked><span class=\"switch-left switch-danger\"><i class=\"icon-ok icon-white\">启用</i></span><label>&nbsp;</label><span class=\"switch-right switch-primary\"><i class=\"icon-remove\">禁用</i></span></div></div>";
                            }
                            return html;
                        }
                    },
                    {
                        mDataProp: "js_Id", sClass: "text-c", sTitle: "操作", sWidth: "10%",
                        mRender: function (data, type, row) {
                            var html = "<a title=\"编辑\" href=\"javascript:;\" onclick=\"common_add('编辑PLC连接配置',\'/elevatorMasterInfo/ElevatorMasterInfoAddOrEdit/" + data + "','700','460')\" class=\"ml-5 btn btn-secondary-outline radius\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe6df; 编辑</i></a>";
                            // html += "<a title=\"删除\" href=\"javascript:;\" onclick=\"DelPlcReadDBInfoAsync('" + data + "')\" class=\"ml-5  btn btn-danger-outline radius\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe609; 删除</i></a>";
                            return html;
                        }
                    }
                    //{mDataProp:"js_Id", sClass:"text-c", sTitle:"操作",sWidth:"10%",
                    // mRender: function(data, type, row){
                    //       var html= "<a title=\"编辑\" href=\"javascript:;\" onclick=\"common_add('编辑PLC连接配置',\'/plcpointinfo/plcpointinfoaddoredit/"+data+"','600','600')\" class=\"ml-5\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe6df;</i></a>";
                    //       html += "<a title=\"删除\" href=\"javascript:;\" onclick=\"DelPlcPointinfoAsync('"+data+"')\" class=\"ml-5\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe609;</i></a>";
                    //          return html;
                    //    }
                    // }
                ],
                oLanguage: { //国际化配置
                    sProcessing: "正在获取数据，请稍后...",
                    sLengthMenu: "显示 _MENU_ 条",
                    sZeroRecords: "没有您要搜索的内容",
                    sInfo: "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",
                    sInfoEmpty: "记录数为0",
                    sInfoFiltered: "(全部记录数 _MAX_ 条)",
                    sInfoPostFix: "",
                    sSearch: "从当前数据中检索： ",
                    sUrl: "",
                    oPaginate: {
                        sFirst: "首页",
                        sPrevious: "上一页",
                        sNext: "下一页",
                        sLast: "尾页"
                    }
                }
            });
        }


        function ModifyElesStatusAsync(isOpen, id) {
            console.log(isOpen);
            console.log(id);
            var msg = "启用";
            var isEnableInt = 0;
            if (isOpen == "true") {
                msg = "禁用";
                isEnableInt = 1;
            }
            popupConfirm("确定要" + msg + "该提升机吗？", 0, function () {
                var data = { 'id': id, 'isEnable': isEnableInt };
                SubmitFormForAjax("/elevatorMasterInfo/modifyelestatus", data, function (data) {
                    if (data.result) {
                        popupAlert(msg + '成功！', 1, function () {
                            location.reload();//刷新页面
                        });
                    } else {
                        popupAlert(msg + '失败！', 1, function (data) {
                            layer.close(data);
                        });
                    }
                }, true);

            });
        }


        function ModifyEleUseAsync(isEnd, id) {
            console.log(isEnd);
            console.log(id);
            var msg = "设为终结点";
            var isNextEndInt = 0;
            if (isEnd == "true") {
                msg = "关闭终结点";
                isNextEndInt = 1;
            }
            popupConfirm("确定要将该提升机" + msg + "吗？", 0, function () {
                var data = { 'id': id, 'isNextEnd': isNextEndInt };
                SubmitFormForAjax("/elevatorJudgeInfo/modifyeleuse", data, function (data) {
                    if (data.result) {
                        popupAlert(msg + '成功！', 1, function () {
                            location.reload();//刷新页面
                        });
                    } else {
                        popupAlert(msg + '失败！', 1, function (data) {
                            layer.close(data);
                        });
                    }
                }, true);

            });
        }


    </script>
}

